package com.ruoyi.monitor.service.impl;

import java.util.*;
import java.util.stream.Collectors;

import com.ruoyi.base.domain.BusWaterSegment;
import com.ruoyi.base.domain.BussinessItemVo;
import com.ruoyi.base.service.IBusWaterSegmentService;
import com.ruoyi.base.service.PublicToolsService;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.BankerSRoundingUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.js.ItemCodeOverData;
import com.ruoyi.common.utils.js.Standard;
import com.ruoyi.common.utils.js.WaterLevelCompute;
import com.ruoyi.monitor.domain.BusWaterAutomonitorevaluateHourdata;
import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.utli.SegmentFormula;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.monitor.mapper.BusWaterAutomonitorevaluateMonthdataMapper;
import com.ruoyi.monitor.domain.BusWaterAutomonitorevaluateMonthdata;
import com.ruoyi.monitor.service.IBusWaterAutomonitorevaluateMonthdataService;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;

/**
 * 自动站月评价Service业务层处理
 * 
 * @author maliang
 * @date 2025-08-11
 */
@Service
public class BusWaterAutomonitorevaluateMonthdataServiceImpl implements IBusWaterAutomonitorevaluateMonthdataService 
{
    @Autowired
    private BusWaterAutomonitorevaluateMonthdataMapper busWaterAutomonitorevaluateMonthdataMapper;
    @Autowired
    private PublicToolsService publicToolsService;
    @Autowired
    private ISysDictDataService sysDictDataService;
    @Resource
    private SegmentFormula segmentFormula;
    @Resource
    private IBusWaterSegmentService busWaterSegmentService;

    /**
     * 查询自动站月评价
     * 
     * @param mn 自动站月评价主键
     * @return 自动站月评价
     */
    @Override
    public BusWaterAutomonitorevaluateMonthdata selectBusWaterAutomonitorevaluateMonthdataByMn(String mn)
    {
        return busWaterAutomonitorevaluateMonthdataMapper.selectBusWaterAutomonitorevaluateMonthdataByMn(mn);
    }

    /**
     * 查询自动站月评价列表
     * 
     * @param busWaterAutomonitorevaluateMonthdata 自动站月评价
     * @return 自动站月评价
     */
    @Override
    public List<BusWaterAutomonitorevaluateMonthdata> selectBusWaterAutomonitorevaluateMonthdataList(BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateMonthdata)
    {
        return busWaterAutomonitorevaluateMonthdataMapper.selectBusWaterAutomonitorevaluateMonthdataList(busWaterAutomonitorevaluateMonthdata);
    }

    /**
     * 新增自动站月评价
     * 
     * @param busWaterAutomonitorevaluateMonthdata 自动站月评价
     * @return 结果
     */
    @Override
    public int insertBusWaterAutomonitorevaluateMonthdata(BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateMonthdata)
    {
        return busWaterAutomonitorevaluateMonthdataMapper.insertBusWaterAutomonitorevaluateMonthdata(busWaterAutomonitorevaluateMonthdata);
    }

    /**
     * 修改自动站月评价
     * 
     * @param busWaterAutomonitorevaluateMonthdata 自动站月评价
     * @return 结果
     */
    @Override
    public int updateBusWaterAutomonitorevaluateMonthdata(BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateMonthdata)
    {
        return busWaterAutomonitorevaluateMonthdataMapper.updateBusWaterAutomonitorevaluateMonthdata(busWaterAutomonitorevaluateMonthdata);
    }

    /**
     * 批量删除自动站月评价
     * 
     * @param mns 需要删除的自动站月评价主键
     * @return 结果
     */
    @Override
    public int deleteBusWaterAutomonitorevaluateMonthdataByMns(String[] mns)
    {
        return busWaterAutomonitorevaluateMonthdataMapper.deleteBusWaterAutomonitorevaluateMonthdataByMns(mns);
    }

    /**
     * 删除自动站月评价信息
     * 
     * @param mn 自动站月评价主键
     * @return 结果
     */
    @Override
    public int deleteBusWaterAutomonitorevaluateMonthdataByMn(String mn)
    {
        return busWaterAutomonitorevaluateMonthdataMapper.deleteBusWaterAutomonitorevaluateMonthdataByMn(mn);
    }

    @Override
    public List<Map> qualityLevelStatis(String id, String startTime, String endTime) {
        List<Map> dataMapList = new ArrayList<>();

        SysDictData dictParam = new SysDictData();
        dictParam.setDictType("water_quality_level");
        List<SysDictData> sysDictDataList = sysDictDataService.selectDictDataList(dictParam);
        Date startDate = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",startTime+"-01 00:00:00");
        Date endDate = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",endTime+"-31 23:59:59");
        List<Map> mapList = busWaterAutomonitorevaluateMonthdataMapper.qualityLevelStatis(id,startDate,endDate);

        for (SysDictData sysDictData : sysDictDataList) {
            Map dataMap = new HashMap<>();
            String value = "0";
            if(!CollectionUtils.isEmpty(mapList)){
                for (Map map : mapList) {
                    String qualityLevelName = StringUtils.getString(map.get("qualityLevelName"));
                    if(qualityLevelName.equals(sysDictData.getDictLabel())){
                        value = StringUtils.getString(map.get("qualityLevelCount"));
                        break;
                    }
                }
            }
            dataMap.put(sysDictData.getDictLabel(),value);
            dataMapList.add(dataMap);
        }
        return dataMapList;
    }
    @Override
    public Map trendStatis(String id, String startTime, String endTime,String items) {
        List<String> queryItemList = new ArrayList<>();
        if(StringUtils.isNotEmpty(items)){
            queryItemList = Arrays.asList(items.split(","));
        }

        Map<String,List<String>> itemDataList = new HashMap<>();
        BussinessItemVo vo = new BussinessItemVo();
        vo.setBussinessCategoryCode("Auto");
        List<Map<String,Object>> itemList=publicToolsService.bussinessItemData(vo);
        Date startDate = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",startTime+"-01 00:00:00");
        Date endDate = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",endTime+"-31 23:59:59");

        List<Map> statisList = busWaterAutomonitorevaluateMonthdataMapper.trendStatis(id,startDate,endDate);

        while(!startDate.after(endDate)){
            String dayTime = DateUtils.parseDateToStr("yyyy-MM",startDate);
            if(itemDataList.containsKey("dateList")){
                List<String> dateList = itemDataList.get("dateList");
                dateList.add(dayTime);
                itemDataList.put("dateList",dateList);
            }else{
                List<String> dateList = new ArrayList<>();
                dateList.add(dayTime);
                itemDataList.put("dateList",dateList);
            }
            String dayTimeNoYear = DateUtils.parseDateToStr("MM",startDate);
            for (Map<String, Object> itemMap : itemList) {
                String itemName = StringUtils.getString(itemMap.get("itemName"));
                if(!queryItemList.contains(itemName)){
                    continue;
                }
                Map itemDataMap = new HashMap();
                itemDataMap.put("dataTime",dayTime);
                itemDataMap.put("item",itemName);
                String effectiveValue = "0";
                for (Map statisMap : statisList) {
                    String statisDay = StringUtils.getString(statisMap.get("dataDay"));
                    String statisItem = StringUtils.getString(statisMap.get("itemName"));
                    String effective = StringUtils.getString(statisMap.get("effectiveValue"));
                    if(statisDay.equals(dayTime) && itemName.equals(statisItem)){
                        if(StringUtils.isNotEmpty(effective)){
                            effectiveValue = effective;
                        }
                        break;
                    }
                }
                if(itemDataList.containsKey(itemName)){
                    List<String> dataList = itemDataList.get(itemName);
                    dataList.add(effectiveValue);
                    itemDataList.put(itemName,dataList);
                }else{
                    List<String> dataList = new ArrayList<>();
                    dataList.add(effectiveValue);
                    itemDataList.put(itemName,dataList);
                }
            }
            startDate = DateUtils.addMonths(startDate,1);
        }
        return itemDataList;
    }

    @Override
    public Map trendQuality(String id, String startTime, String endTime) {
        Map<String,List<String>> itemDataList = new HashMap();

        SysDictData sysDictDataParam = new SysDictData();
        sysDictDataParam.setDictType("water_quality_level");
        List<SysDictData> sysDictDataList = sysDictDataService.selectDictDataList(sysDictDataParam);
        List<String> levelList = new ArrayList<>();
        sysDictDataList.sort(Comparator.comparing(SysDictData::getDictSort).reversed());
        for (SysDictData sysDictData : sysDictDataList) {
            levelList.add(sysDictData.getDictLabel());
        }
        itemDataList.put("levelList",levelList);

        Date startDate = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",startTime+"-01 00:00:00");
        Date endDate = DateUtils.dateTime("yyyy-MM-dd HH:mm:ss",endTime+"-31 23:59:59");

        BusWaterAutomonitorevaluateMonthdata busWaterAutomonitorevaluateHourdataParam = new BusWaterAutomonitorevaluateMonthdata();
        busWaterAutomonitorevaluateHourdataParam.setSegmentid(id);
        busWaterAutomonitorevaluateHourdataParam.setStartTime(startDate);
        busWaterAutomonitorevaluateHourdataParam.setEndTime(endDate);
        List<BusWaterAutomonitorevaluateMonthdata> statisList = busWaterAutomonitorevaluateMonthdataMapper.selectBusWaterAutomonitorevaluateMonthdataList(busWaterAutomonitorevaluateHourdataParam);

        while(!startDate.after(endDate)){
            String dayTime = DateUtils.parseDateToStr("yyyy-MM",startDate);
            if(itemDataList.containsKey("dateList")){
                List<String> dateList = itemDataList.get("dateList");
                dateList.add(dayTime);
                itemDataList.put("dateList",dateList);
            }else{
                List<String> dateList = new ArrayList<>();
                dateList.add(dayTime);
                itemDataList.put("dateList",dateList);
            }
            String itemName = "level";

            Map itemDataMap = new HashMap();
            itemDataMap.put("dataTime",dayTime);
            itemDataMap.put("item",itemName);
            String level = "无类别";

            for (BusWaterAutomonitorevaluateMonthdata statisMap : statisList) {
                String statisDay = DateUtils.parseDateToStr("yyyy-MM",statisMap.getSampletime());
                if(statisDay.equals(dayTime)){
                    if(StringUtils.isNotEmpty(statisMap.getQualitylevelname())){
                        level = statisMap.getQualitylevelname();
                    }
                    break;
                }
            }
            if(itemDataList.containsKey(itemName)){
                List<String> dataList = itemDataList.get(itemName);
                dataList.add(level);
                itemDataList.put(itemName,dataList);
            }else{
                List<String> dataList = new ArrayList<>();
                dataList.add(level);
                itemDataList.put(itemName,dataList);
            }
            startDate = DateUtils.addMonths(startDate,1);
        }
        return itemDataList;
    }

    @Override
    public List<Map<String, Object>> getWaterAutoEvaluateMonthList(Map<String, Object> params) {
        List<Map<String, Object>> resultList=new ArrayList<>();
        if (StringUtils.isEmpty(params.get("beginTime")!=null  ? params.get("beginTime").toString() : "") || StringUtils.isEmpty(params.get("endTime")!=null ? params.get("endTime").toString() : "")){
            params.put("beginTime", DateUtils.getFirstDayOfMonth(DateUtils.addMonths(DateUtils.getNowDate(),-1)));
            params.put("endTime", DateUtils.getLastDayOfMonth(DateUtils.addMonths(DateUtils.getNowDate(),-1)));
        }else {
            params.put("beginTime", DateUtils.getFirstDayOfMonth(DateUtils.parseDate(params.get("beginTime").toString())));
            params.put("endTime", DateUtils.getLastDayOfMonth(DateUtils.parseDate(params.get("endTime").toString())));
        }
        resultList = busWaterAutomonitorevaluateMonthdataMapper.getWaterAutoEvaluateMonthList(params);
        if (StringUtils.isEmpty(resultList)){
            params.put("beginTime", DateUtils.getFirstDayOfMonth(DateUtils.addMonths(DateUtils.getNowDate(),-2)));
            params.put("endTime", DateUtils.getLastDayOfMonth(DateUtils.addMonths(DateUtils.getNowDate(),-2)));
            resultList = busWaterAutomonitorevaluateMonthdataMapper.getWaterAutoEvaluateMonthList(params);
        }
        return resultList;
    }

    @Override
    public List<Map<String, Object>> getWaterAutoMonitorMonthList(Map<String, Object> params) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (StringUtils.isEmpty(params.get("beginTime")!=null  ? params.get("beginTime").toString() : "") || StringUtils.isEmpty(params.get("endTime")!=null ? params.get("endTime").toString() : "")){
            params.put("beginTime", DateUtils.getFirstDayOfMonth(DateUtils.addMonths(DateUtils.getNowDate(),-1)));
            params.put("endTime", DateUtils.getLastDayOfMonth(DateUtils.addMonths(DateUtils.getNowDate(),-1)));
        }else {
            params.put("beginTime", DateUtils.getFirstDayOfMonth(DateUtils.parseDate(params.get("beginTime").toString())));
            params.put("endTime", DateUtils.getLastDayOfMonth(DateUtils.parseDate(params.get("endTime").toString())));
        }
        List<Map<String, Object>> dataList= busWaterAutomonitorevaluateMonthdataMapper.getWaterAutoMonitorDayList(params);
        if(StringUtils.isNotEmpty(dataList)){
            //获取检测因子配置
            BussinessItemVo vo = new BussinessItemVo();
            vo.setBussinessCategoryCode("Auto");
            List<Map<String, Object>> itemList = publicToolsService.bussinessItemData(vo);
            // 对dataList 进行分组，按segmentId进行分组
            Map<String,List<Map<String, Object>>> segmentIdMap = dataList.stream().collect(
                    Collectors.groupingBy(map -> (String)map.get("segmentId"))
            );
            // 循环分组的数据
            segmentIdMap.forEach((segmentId, segmentIdList) -> {
                // 对segmentIdList 按时间分组sampleTime
                Map<String,List<Map<String, Object>>> segmentTimeMap = segmentIdList.stream().collect(
                        Collectors.groupingBy(map -> (String)map.get("sampleTime"))
                );
                // 循环分组的数据进行行转列
                segmentTimeMap.forEach((sampleTime, dataTimeList) -> {
                    Map<String,Object> dataMap = new HashMap();
                    dataMap.put("segmentId",dataTimeList.get(0).get("segmentId"));
                    dataMap.put("segmentName",dataTimeList.get(0).get("segmentName"));
                    dataMap.put("sampleTime",sampleTime);
                    dataTimeList.forEach(map -> {
                        itemList.forEach(itemMap -> {
                            String itemCode = StringUtils.getString(map.get("itemCode"));
                            if(itemCode.equals(itemMap.get("itemCode"))){
                                dataMap.put(itemMap.get("eNName").toString(),map.get("effectiveValue"));
                            }
                        });
                    });
                    resultList.add(dataMap);
                });
            });
        }
        return resultList;
    }

    @Override
    public List<Map<String, Object>> getWaterAutoEvaluateYearList(Map<String, Object> params) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        // 先获取该年的月的监测数据，根据月的监测数据求平均值为年的监测数据
        if (StringUtils.isEmpty(params.get("beginTime")!=null  ? params.get("beginTime").toString() : "")){
            params.put("beginTime", DateUtils.getFirstDayOfYear(DateUtils.addYears(DateUtils.getNowDate(),-1)));
            params.put("endTime", DateUtils.getLastDayOfYear(DateUtils.addYears(DateUtils.getNowDate(),-1)));
        }else {
            params.put("beginTime", DateUtils.getFirstDayOfYear(DateUtils.parseDate(params.get("beginTime").toString())));
            params.put("endTime", DateUtils.getLastDayOfYear(DateUtils.parseDate(params.get("beginTime").toString())));
        }
        List<Map<String, Object>> itemYearMonitorList = getWaterAutoItemYearMonitorList(params);
        // 通过每个因子的年数据计算评价数据
        if (StringUtils.isNotEmpty(itemYearMonitorList)){
            // 通过断面分组，计算每个断面的年评价数据
            Map<String,List<Map<String, Object>>> segmentIdMap = itemYearMonitorList.stream().collect(
                    Collectors.groupingBy(map -> (String)map.get("segmentId"))
            );
            segmentIdMap.forEach((segmentId, segmentIdList) -> {
                Map<String,Object> resultMap = new HashMap();
                // 根据断面id获取断面信息
                BusWaterSegment busWaterSegment = busWaterSegmentService.selectBusWaterSegmentByID(segmentId);
                // 定义最大水质级别为该断面水质评价数据
                List<Map<String, Object>> evaluateMapList = new ArrayList<>();
                segmentIdList.forEach(itemYearDataMap -> {
                    // 判断是否需要评价 isEvalute =1 需要评价
                    if ("1".equals(String.valueOf(itemYearDataMap.get("isEvalute")))){
                        Map<String,Object> evaluateMap = new HashMap();
                        Map segmentStandardValuemap = new HashMap();
                        segmentStandardValuemap.put("ItemCode", itemYearDataMap.get("itemCode"));
                        segmentStandardValuemap.put("ID", itemYearDataMap.get("segmentId"));
                        List<Standard> standards = segmentFormula.segmentStandardValue(segmentStandardValuemap);
                        //需要注意Standardlist 传入值要单个因子的
                        Integer integerNum = ItemCodeOverData.GetSingleType(Double.parseDouble(String.valueOf(itemYearDataMap.get("effectiveValue"))),
                                standards, itemYearDataMap.get("itemCode").toString(),
                                String.valueOf(itemYearDataMap.get("effectiveValue")), 0);
                        //获取到对应级别之后进行转换成水质级别类型名称
                        if (integerNum == null) {
                            //断面计算出的级别
                            integerNum = 0;
                        }
                        //转换水质级别名称
                        String levelName = WaterLevelCompute.GetLevelName(integerNum,"无类别");
                        evaluateMap.putAll(itemYearDataMap);
                        evaluateMap.put("qualityLevel", String.valueOf(integerNum));
                        evaluateMap.put("qualityLevelName", levelName);
                        evaluateMapList.add(evaluateMap);
                    }
                });
                if (StringUtils.isNotEmpty(evaluateMapList)){
                    //计算evaluateMapList 下的qualityLevel 计算最大值，并获取所对应的map对象；
                    Optional<Map<String, Object>> maxQualityLevelMap = evaluateMapList.stream()
                            .max(Comparator.comparingInt(map -> Integer.parseInt(StringUtils.getString(map.get("qualityLevel")))));
                    if (maxQualityLevelMap.isPresent()) {
                        // 计算水质是否超标，计算的断面水质等级大于断面基础表的目标水质等级为超标
                        Integer qualityLevel = Integer.parseInt(StringUtils.getString(maxQualityLevelMap.get().get("qualityLevel")));//计算的断面水质等级
                        Integer targetLevel = Integer.parseInt(StringUtils.getString(busWaterSegment.getTargetlevel()));// 断面目标水质等级
                        if(targetLevel<qualityLevel){
                            resultMap.put("isOverStandard", "1");
                        }else {
                            resultMap.put("isOverStandard", "0");
                        }
                        resultMap.put("qualityLevel", qualityLevel);
                        resultMap.put("qualityLevelName", WaterLevelCompute.GetLevelName(qualityLevel,"无类别"));
                        resultMap.put("waterQuality", WaterLevelCompute.getPollutionLevelName(qualityLevel,"无类别"));
                        resultMap.put("targetLevel",busWaterSegment.getTargetlevel());
                        resultMap.put("targetLevelName",busWaterSegment.getTargetlevelname());
                        resultMap.put("sampleTime", maxQualityLevelMap.get().get("sampleTime"));
                    }
                }
                resultMap.put("riverName",busWaterSegment.getRivername());
                resultMap.put("county",busWaterSegment.getCounty());
                resultMap.put("segmentId", segmentId);
                resultMap.put("segmentName", segmentIdList.get(0).get("segmentName"));
                resultList.add(resultMap);
            });
        }
        return resultList;
    }

    @Override
    public List<Map<String, Object>> getWaterAutoMonitorYearList(Map<String, Object> params) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        // 先获取该年的月的监测数据，根据月的监测数据求平均值为年的监测数据
        if (StringUtils.isEmpty(params.get("beginTime")!=null  ? params.get("beginTime").toString() : "")){
            params.put("beginTime", DateUtils.getFirstDayOfYear(DateUtils.addYears(DateUtils.getNowDate(),-1)));
            params.put("endTime", DateUtils.getLastDayOfYear(DateUtils.addYears(DateUtils.getNowDate(),-1)));
        }else {
            params.put("beginTime", DateUtils.getFirstDayOfYear(DateUtils.parseDate(params.get("beginTime").toString())));
            params.put("endTime", DateUtils.getLastDayOfYear(DateUtils.parseDate(params.get("beginTime").toString())));
        }
        // 获取年监测时间
        List<Map<String, Object>> itemYearMonitorList = getWaterAutoItemYearMonitorList(params);
        if (StringUtils.isNotEmpty(itemYearMonitorList)){
            //断面分组
            Map<String,List<Map<String, Object>>> segmentIdMap = itemYearMonitorList.stream().collect(
                    Collectors.groupingBy(map -> (String)map.get("segmentId"))
            );
            segmentIdMap.forEach((segmentId, segmentIdList) -> {
                Map<String,Object> resultMap = new HashMap();
                resultMap.put("segmentId",segmentId);
                resultMap.put("segmentName",segmentIdList.get(0).get("segmentName"));
                resultMap.put("sampleTime",segmentIdList.get(0).get("sampleTime"));
                segmentIdList.forEach(map -> {
                    resultMap.put(map.get("eNName").toString(),map.get("effectiveValue"));
                });
                resultList.add(resultMap);
            });
        }
        return resultList;
    }

    // 计算年的所有因子监测数据
    public List<Map<String, Object>> getWaterAutoItemYearMonitorList(Map<String, Object> params) {
        List<Map<String, Object>> itemList = new ArrayList<>();
        // 获取监测时间的所有月份
        List<Map<String, Object>> monthDataList = busWaterAutomonitorevaluateMonthdataMapper.getWaterAutoMonitorDayList(params);
        if (StringUtils.isNotEmpty(monthDataList)){
            // 获取自动站的因子配置
            BussinessItemVo vo = new BussinessItemVo();
            vo.setBussinessCategoryCode("Auto");
            List<Map<String, Object>> itemBasList = publicToolsService.bussinessItemData(vo);
            //对断面进行分组
            Map<String,List<Map<String, Object>>> segmentIdMap = monthDataList.stream().collect(
                    Collectors.groupingBy(map -> (String)map.get("segmentId"))
            );
            // 循环数据
            segmentIdMap.forEach((segmentId, segmentIdList) -> {
                // 通过监测因子进行分组，获取该监测因子的所有数据
                Map<String,List<Map<String, Object>>> itemCodeMap = segmentIdList.stream().collect(
                        Collectors.groupingBy(map -> (String)map.get("itemCode"))
                );
                // 循环因子数据
                itemCodeMap.forEach((itemCode, itemCodeList) -> {
                    // 计算itemCodeList中的effectiveValue 数据均值
                    OptionalDouble avg = itemCodeList.stream()
                            .mapToDouble(map -> Double.parseDouble(StringUtils.getString(map.get("effectiveValue"))))
                            .average();
                    double effectiveValueAvg = avg.orElse(0.0); // 提供默认值
                    // 获取该因子需要保留几位小数
                    itemBasList.forEach(itemMap -> {
                        if(itemCode.equals(itemMap.get("itemCode"))){
                            Map<String,Object> itemDatMap = new HashMap();
                            itemDatMap.put("segmentId",segmentId);
                            itemDatMap.put("segmentName",segmentIdList.get(0).get("segmentName"));
                            itemDatMap.put("sampleTime",DateUtils.parseDateToStr("yyyy",DateUtils.parseDate(itemCodeList.get(0).get("sampleTime").toString())));
                            int keepPointBits = Integer.parseInt(StringUtils.getString(itemMap.get("keepPointBits")));
                            String effectiveValue = BankerSRoundingUtils.sciCal(effectiveValueAvg,keepPointBits);
                            itemDatMap.put("eNName",itemMap.get("eNName").toString());
                            itemDatMap.put("itemName",itemMap.get("itemName"));
                            itemDatMap.put("effectiveValue",effectiveValue);
                            itemDatMap.put("itemCode",itemCode);
                            itemDatMap.put("isEvalute",itemMap.get("isEvalute"));
                            itemList.add(itemDatMap);
                        }
                    });
                });
            });
        }
        return itemList;
    }



}
